package com.ss.android.wenda.answer.detail2;

import android.view.View;
import android.widget.AbsListView;
import android.widget.ListView;
import com.ss.android.article.base.feature.detail2.article.a.NewDetailViewHolder;
import com.ss.android.common.util.NetworkUtils;

import im.quar.autolayout.utils.AutoUtils;

final class x implements AbsListView.OnScrollListener {
    private final NewAnswerDetailFragment a;

    x(NewAnswerDetailFragment arg1) {
        this.a = arg1;

    }

    public final void onScroll(AbsListView arg8, int arg9, int arg10, int arg11) {
        int v6 = 2;
        int v2 = 0;
        NewDetailViewHolder v3 = NewAnswerDetailFragment.a(this.a);
        if(v3 != null) {
            NewAnswerDetailFragment.a(this.a, v3);
            NewAnswerDetailFragment.b(this.a, v3);
            NewAnswerDetailFragment.c(this.a, v3);
            NewAnswerDetailFragment.d(this.a, v3);
            NewAnswerDetailFragment.e(this.a, v3);
            if(v3.mNewDetailPageExtra != null) {
                v3.mNewDetailPageExtra.a(NewAnswerDetailFragment.p(this.a));
            }

            int v4 = arg9 + arg10;
            NewAnswerDetailFragment v5 = this.a;
            boolean v0 = v4 <= ((ListView)arg8).getHeaderViewsCount() || v3.mDetailScrollView.getScrollY() <= 0 ? false : true;
            NewAnswerDetailFragment.b(v5, v0);
            if(!NewAnswerDetailFragment.q(this.a) && (NewAnswerDetailFragment.r(this.a))) {
                v3.mNewDetailAdapter.notifyDataSetChanged();
                NewAnswerDetailFragment.s(this.a);
            }

            if((NewAnswerDetailFragment.t(this.a)) && (NewAnswerDetailFragment.u(this.a)) && arg9 == 0 && arg8.getChildCount() > 0) {
                View v0_1 = arg8.getChildAt(0);
                int[] v5_1 = new int[v6];
                int[] v6_1 = new int[v6];
                v0_1.getLocationOnScreen(v5_1);
                v3.mDetailScrollView.getLocationInWindow(v6_1);
                if(v5_1[1] > v6_1[1] - AutoUtils.scaleValue(44)) {
                    NewAnswerDetailFragment.c(this.a, false);
                    NewAnswerDetailFragment.a(this.a).mDetailScrollView.webViewScrollTo(true);
                }
            }

            if(v4 < arg11) {
                return;
            }

            if(((arg8 instanceof ListView)) && arg11 <= ((ListView)arg8).getHeaderViewsCount() + ((ListView)arg8).getFooterViewsCount()) {
                return;
            }

            if(!NetworkUtils.isNetworkAvailable(this.a.mContext)) {
                return;
            }

            NewAnswerDetailFragment v0_2 = this.a;
            if(v3 == null || v3.mCommentTabCache == null || (v0_2.d()) || (v3.mCommentTabCache.load[0]) || !v3.mCommentTabCache.mArticleTabComments[0].hasMore) {
                v2 = -1;
            }

            if(v2 < 0) {
                return;
            }

            NewAnswerDetailFragment.v(this.a);
        }
    }

    public final void onScrollStateChanged(AbsListView arg3, int arg4) {
        NewDetailViewHolder v0 = NewAnswerDetailFragment.a(this.a);
        if(v0 != null && !v0.mNewDetailAdapter.h) {
            v0.mNewDetailAdapter.h = true;
        }
    }
}

